import {
	useRequest
} from "./request.js";

import {
	useUserStore
} from "../stores/useUserStore.js";

export const useMenuApis = () => {

	const request = useRequest();

	// 根据日期查询菜单关联菜品
	function getMenuByDate(date) {
		return request.get(`/api/menus/${date}/dishes`);
	}

	// 创建、修改菜单
	function updateMenu({
		date,
		dishesIdList
	}) {
		return request.put(`/api/menus/${date}/dishes`, {
			data: {
				dishesIdList
			},
			header: {
				authorization: useUserStore().token
			}
		});
	}

	// 查询本周和下周菜单
	function getWeeksMenu() {
		return request.get(`/api/menus/weeks/dishes`)
	}

	return {
		getMenuByDate,
		updateMenu,
		getWeeksMenu,
	}
}